<template>
     <div id="bodgc">
      <el-form ref="form" :model="form" label-width="80px" >
         <fieldset class="gameInp">
         <legend>初创玩家数据</legend>
         <div class="disC">
          <el-form-item label="绑定筹码 :" label-width="100px">
            <el-input v-model="v0"></el-input>
          </el-form-item>
          <el-form-item label="宝石 :" label-width="100px">
            <el-input v-model="v1"></el-input>
          </el-form-item>
          <el-form-item label="非绑定筹码 :" label-width="110px">
            <el-input v-model="v2"></el-input>
          </el-form-item>
          </div>
          </fieldset>
        
        <div class="chanBring">
          <div class="gameInput" style="color:#c0c4cc; background-color:#f5f7fa;">
             <el-input placeholder="请输入内容" v-model="input1" :disabled="true"></el-input>
             <span>宝石</span>
          </div>
          <img class="image" src="../assets/web.png" alt="">
           <div class="gameInput">
              <el-input placeholder="请输入内容" v-model="rateData[0].value" ></el-input>
              <span>绑定筹码</span>
          </div>
        </div>
          <div style="width:100%;text-align:center">
             <el-button  class="btnSave" type="primary" @click="savegameMessage">保存</el-button>
          </div>
      </el-form>
     </div>
</template>
<script>
  // const cityOptions = ['支付宝', '微信', '银联'];
import gameConfig from '../server/gameConfig.js'
     export default {
       data(){
          return {
           checkList: [],
           turnOpens:'',
           checkAll: true,
           checkedCities: [],
           cities: [],
           isIndeterminate: true,
           turn: false,
           rateData:[
            {value:''}
          ],
          input1:'1',
          forms:[
            {
              value:'1'
            },
             {
              value: '2'
            },
            {
              value: '3'
            },
             {
              value: '4'
            }
          ],
         middle:{
           id:'1',
           alipay:'0',
           maintain:'0',
           new:false,
           unionPay:'0',
           weChat:'0'
         },
        form: {
            name: '',
            region: '',
            date1: '',
            date2: '',
            delivery: false,
            type: [],
            resource: '',
            desc: ''
          },
          gameConfig:gameConfig,
          v0: '',
          v1: '',
          v2: '',
          
      }
      },
      created(){
        this.getgameMessage();
        this.getGameRate();
      },
     methods:{
      //   handleCheckAllChange(val) {
      //   this.checkedCities = val ? cityOptions : [];
      //   this.isIndeterminate = false;
      // },
      // handleCheckedCitiesChange(value) {
      //   let checkedCount = value.length;
      //   this.checkAll = checkedCount === this.cities.length;
      //   this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
      // },
       savegameMessage() {
          this.rateData.forEach((item)=>{
              this.$api.changeRate(item).then(res => {
               if (res.code === '000000') {
                 this.$alert('保存成功'); 
                 this.getGameRate();
                 }
             })
          })
        this.forms.forEach(item => {
          if (item.key == 0) {
            item.value = this.v0;
            this.$api.reviseMes(item).then(res => {
              if (res.code === '000000') {
                this.getgameMessage();
                this.getGameRate();
              }
            })
          }
          if (item.key == 1) {
            item.value = this.v1
            this.$api.reviseMes(item).then(res => {
              if (res.code === '000000') {
                this.getgameMessage();
                this.getGameRate();
              }
            })
          }
          if (item.key == 2) {
            item.value = this.v2
            this.$api.reviseMes(item).then(res => {
              if (res.code === '000000') {
                this.getgameMessage();
                this.getGameRate();
              }
            })
          }
          // if (item.key == 3) {
          //   item.value = this.v3;
          //   item.value = item.value/100;
          //   this.$api.reviseMes(item).then(res => {
          //     if (res.code === '000000') {
          //       this.getgameMessage();
          //       this.getGameRate();
          //     }
          //   })
          // }
        })
        
      },
      // saa(){
      //    this.$message({
      //     message: '恭喜你，这是一条成功消息',
      //     type: 'success'
      //   });
      // },
      // 获取游戏配置信息
      getgameMessage(){
        console.log('this.froms')
       console.log(this.froms)
         this.$api.getgameConfig(this.froms).then(res=>{
            console.log('VVVVVVVVVv')
            if(res.code=='000000'){
              console.log('this.form888888888888')
              console.log(res.data.list)
              this.forms = res.data.list;
              // this.forms[0].value = parseFloat(this.forms[0].value)*100;
            }
          })
      },
      // 获取汇率信息
      getGameRate(){
         this.$api.getRate(this.froms).then(res=>{
            if(res.code=='000000'){
              console.log('this.rateData')
              console.log(this.rateData)
               this.rateData = res.data;
            }
          })
      },
     },
     watch: {
        forms (val) {
          // console.log(val)
          if (typeof val[0].key == 'number') {
           val.forEach(item => {
             if (item.key == 0) {
               this.v0 = item.value
             }
              if (item.key == 1) {
               this.v1 = item.value
             }
              if (item.key == 2) {
               this.v2 = item.value
             }
            //   if (item.key == 3) {
            //    this.v3 = item.value
            //  }
           })
          }
        }
      }
     }
</script>
<style>
#bodgc #lab{
  width:250px;
}

#bodgc .el-input__inner{
  width:150px;
}
#bodgc label{
  font-size:16px;
  color:#606266;
}

  #bodgc element.style {
    margin-left: 110px!important;
}
  #bodgc .el-form-item__content{
    margin-left: 110px!important;
  }
#bodgc .disC{
  margin-top:25px;
  display:flex;
  flex-wrap:wrap;
}

#bodgc{
  padding:10px 20px;
}
#bodgc .btnSave{
  width:100px;
  margin:2vw auto;
}
#bodgc .chanBring label{
  padding-left:5px;
  float:left;
  text-align:left;
}
#bodgc .chanBring{
  display:flex;
  align-items: center;
  width:500px;
  margin:0 auto;
  justify-content:space-between;
  
}
#bodgc .inpSty{
  width:50px;
  -webkit-appearance: none;
  background-color: #fff;
  border-radius: 4px;
  border: 1px solid #dcdfe6;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  color: #606266;
  display: inline-block;
  font-size: inherit;
  height: 40px;
  line-height: 1;
  outline: 0;
  padding: 0 15px;
}
#bodgc .disBring{
  display:flex;
}
#bodgc .image{
  height:60px;
  width:130px;
  margin:0 20px;
}
  #bodgc .widthInput{
    width:160px;
  }
  #bodgc .gameInp{
    height:auto;
    margin-bottom:30px;
  }
  #bodgc h2{
    margin:0;
  }
 
  #bodgc .pStyle{
    width:300px;
    margin:15px auto;
  }
  #bodgc .btnCen{
    width:170px;
    margin:0 auto;
  }
   #bodgc .chanBring .el-input__inner{
     text-align:center;
    width:50px;
    padding:0 0 0 10px;
    border: none;
  }
  #bodgc .gameInput{
    
   
    dispaly:flex;
    width:200px;
      padding-right:10px;
    border-radius: 4px;
    border: 1px solid #dcdfe6;
  }
#bodgc .el-input{
  width:50%;
}
</style>